package duijiangji;

import com.unicom.office.dataitem.NumberDataItem;
import com.unicom.office.dataitem.StringDataItem;
import com.unicom.office.runtime.OfficeRuntime;
import com.unicom.office.templatefunc.TemplateFunc;
import com.unicom.office.type.StringTypeItem;
import com.unicom.office.type.TypeItem;
import com.unicom.office.unit.OfficeUnit;

import java.util.List;

public class Maolilv extends TemplateFunc {
    public Object run(List<Object> params, OfficeRuntime officeRuntime) {
        NumberDataItem num1 = (NumberDataItem) params.get(0);
        NumberDataItem num2 = (NumberDataItem) params.get(1);
        double v = (num2.getDoubleValue() - num1.getDoubleValue()) / num2.getDoubleValue();
        Double v1 = Math.round(v * 1000) * 0.1;
        return StringDataItem.create(v1.toString() + "%");
    }

    public void runForMatch(OfficeUnit unit, List<Object> params, OfficeRuntime officeRuntime) {

    }

    public String getName() {
        return "maolilv";
    }

    public TypeItem getType() {
        return StringTypeItem.INSTANCE;
    }
}
